let mixinList = require('../../common/mixinList');
Page({
    behaviors: [mixinList],
    data: {
        navInfo: '',
        reqUrl: '/api/supplier/items',
        usePrivateMethod: true //使用私有方法
    },
    onLoad: function(options) {
        this.setData({
            navInfo: getApp().globalData.navInfo
        })
        if (options.uid) { //绑定关系
            return this.redirect_login(options.uid)
        }
        this.getList(true)
    },
    getParamsData() { //页面特殊的请求参数，需要时在页面内覆盖此方法，默认返回{}
        return { so: this.data.searchText }
    },
    privateMethod(refresh, res) {
        return new Promise(resolve => {
            res.data.forEach(item => {
                if (item.face) item.face = item.face + '!img_100'
                if (item.logo) item.logo = item.logo + '!img_100'
                item.product_list.map(good => {
                    return good.product_img = good.product_img + "!img_200"
                })
            })

            resolve(res.data)
        })
    },
    toGoodDetail(e) {
        wx.navigateTo({
            url: `/pages/good_detail/index?id=${e.detail}`
        })
    },
    refresh() {},
    //点击分享
    onShareAppMessage() {
        let options = '/pages/supplier/index'
        if (this.data.userInfo) options += `?uid=${this.data.userInfo.uid}`
        return {
            path: options
        }
    }
})